package com.zyz.I_多线程.常用方法;

/**
 * @author: vick
 * @Date: 2025/3/22
 * @Description: 获取main线程对象的名称和优先级
 * @version: 1.0
 */
public class PriorityThread2 {
    public static void main(String[] args) {
        Runnable runnable = () -> {
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName() + "执行");
            }
        };

        Thread threadA = new Thread(runnable, "子线程A");
        Thread threadB = new Thread(runnable, "子线程B");
        Thread threadC = new Thread(runnable, "子线程C");

        threadA.setPriority(Thread.MIN_PRIORITY);
        threadB.setPriority(Thread.MIN_PRIORITY);
        threadC.setPriority(Thread.MAX_PRIORITY);

        threadA.start();
        threadB.start();
        threadC.start();
    }
}
